<?php   
  function getSocialData($social, $username) {
    $ci = curl_init();
    curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
    switch($social){
      case 'twitter':
        curl_setopt($ci, CURLOPT_URL, 'http://api.twitter.com/1/users/show/'.$username.'.json');
        $user = json_decode(curl_exec($ci));
        return array('name' => $user->name,
                     'link' => 'http://twitter.com/#!/'.$user->screen_name,
                     'avatar' => $user->profile_image_url);
      break;
      case 'facebook':
        curl_setopt($ci, CURLOPT_URL, 'https://graph.facebook.com/'.$username);
        curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, false);
        $user = json_decode(curl_exec($ci));
        return array('name' => $user->name,
                     'link' => $user->link,
                     'avatar' => 'https://graph.facebook.com/'.$user->id.'/picture');
      break;
    }
    curl_close($ci);
  }
?>

